package reply

import (
	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gfer/app/model/reply"
)

const (
	TypeReply    = 0 // 回复
	TypeArticle  = 1 // 文章
	TypeQuestion = 2 // 问答
	PageSize     = 0
)

// 获得回复列表
func GetListByTid(t int, tid uint, page int) []*reply.Entity {
	list, err := reply.Model.
		FieldsEx(reply.Columns.Content).
		Where(reply.Columns.Type, t).
		Where(reply.Columns.Tid, tid).
		Order(reply.Columns.Id, "desc").
		Page(page, PageSize).
		All()
	if err != nil {
		g.Log().Panic(err)
	}
	return list
}

// 获得回复列表(带详情)
func GetListContentByTid(t int, tid uint, page int) []*reply.Entity {
	list, err := reply.Model.
		Where(reply.Columns.Type, t).
		Where(reply.Columns.Tid, tid).
		Order(reply.Columns.Id, "desc").
		Page(page, PageSize).
		All()
	if err != nil {
		g.Log().Panic(err)
	}
	return list
}
